{include file="public/toper"/}
<script type="text/javascript" src="/static/js/base64.js"></script>
<style>
    #edui1_iframeholder{ height: 300px;}
</style>
<div class="x-body">
    <form action="" method="post" class="layui-form" id="forms">
        <div class="layui-form-item">
            <label class="layui-form-label">
                <span class="x-red">*</span>门店名称
            </label>
            <div class="layui-input-inline">
                <input type="text" value="" name="name" required="" lay-verify="required" autocomplete="off" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>10个字符以内
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">
                <span class="x-red">*</span>门店电话
            </label>
            <div class="layui-input-inline">
                <input type="text" value="" name="phone" required="" lay-verify="required" autocomplete="off" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">
                <span class="x-red">*</span>电话号码
            </label>
            <div class="layui-input-inline">
                <input type="text" value="" name="tel" required="" lay-verify="required" autocomplete="off" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>座机号
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">
                <span class="x-red">*</span>户名
            </label>
            <div class="layui-input-inline">
                <input type="text" value=""  name="username" required="" lay-verify="required" autocomplete="off" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>20个字符以内
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">
                <span class="x-red">*</span>开户行
            </label>
            <div class="layui-input-inline">
                <input type="text" value="" name="bank" required="" lay-verify="required" autocomplete="off" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>40个字符以内
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">
                <span class="x-red">*</span>账号
            </label>
            <div class="layui-input-inline">
                <input type="number" value="" name="number" required="" lay-verify="required" autocomplete="off" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">
                <span class="x-red">*</span>门店账号名称
            </label>
            <div class="layui-input-inline">
                <input type="text" value="" name="store_name" required="" lay-verify="required" autocomplete="off" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>10个字符以内
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">
                <span class="x-red">*</span>门店账号密码
            </label>
            <div class="layui-input-inline">
                <input type="password" value="" name="store_pass" required=""  autocomplete="off" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>为空则不改
            </div>
        </div>


        <div class="layui-form-item">
            <label class="layui-form-label">
                <span class="x-red">*</span>门店图片
            </label>
            <div class="layui-input-inline layui-upload" id="upload-thumb">
                <button type="button" class="layui-btn layui-btn-primary" id="image"><i class="layui-icon"></i>上传图片</button>
                <div class="layui-upload-list">
                    <img class="layui-upload-list imgsc" id="demo">
                    <p id="demoText"></p>
                </div>
            </div>
        </div>



        <div class="layui-form-item">
            <label class="layui-form-label">
                <span class="x-red">*</span>门店地址
            </label>
            <div class="layui-input-inline">
                <input type="text" value="" id="dz" name="address" required="" lay-verify="required" autocomplete="off" class="layui-input">
                <input type="hidden" value="" id="lag" name="lag" required="" class="layui-input">
                <iframe src="/map/index.html" name="f_map" id="f_map" style="width: 960px;height: 615px;" frameborder="0" scrolling="yes" class="x-iframe"></iframe>
            </div>
        </div>



        <div class="layui-form-item">
            <label class="layui-form-label">
                <span class="x-red">*</span>图文介绍
            </label>
            <div class="layui-input-inline" style="width: 50%;">
                <textarea id="store_desc" name="store_desc" class="store_desc"></textarea>
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label"></label>
            <button  class="layui-btn" lay-filter="forms" lay-submit>提交</button>
        </div>
    </form>
</div>
<!-- 配置文件 -->
<script type="text/javascript" src="/static/utf8-php/ueditor.config.js"></script>
<!-- 编辑器源码文件 -->
<script type="text/javascript" src="/static/utf8-php/ueditor.all.js"></script>
<!-- 实例化编辑器 -->
<script type="text/javascript">
    var goods_introduce = UE.getEditor('store_desc');
</script>
<script>
    layui.use(['form','layer','upload'], function(){
        $ = layui.jquery;
        var form = layui.form
            ,layer = layui.layer,
        upload = layui.upload;
        //普通图片上传
        var uploadInst = upload.render({
            elem: '#image',
            url: "{:url('Upload/upimage_s')}",
            ext: 'jpg|png|gif',
            drag:false,
            before: function(obj){
                //预读本地文件示例，不支持ie8
                obj.preview(function(index, file, result){
                    $('#demo').attr('src', result); //图片链接（base64）
                });
            },
            done: function(res){
                //如果上传失败
                if(res.code == 200 ){
                    $('#demo').attr('src',res.src);
                    $('#upload-thumb').append('<input type="hidden" name="img" value="'+ res.data.path +'">');
                }else {

                    layer.msg(res.msg);
                }
                //上传成功
            },
            error: function(){
                //演示失败状态，并实现重传
                var demoText = $('#demoText');
                demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-mini demo-reload">重试</a>');
                demoText.find('.demo-reload').on('click', function(){
                    uploadInst.upload();
                });
            }
        });



        form.on('submit(forms)', function(data) {
            var _form = '';
            if ($(this).attr('data-form')) {
                _form = $($(this).attr('data-form'));
            } else {
                _form = $(this).parents('form');
            }

            $('.store_desc').val(base64.encode(UE.getEditor('store_desc').getContent()));
            layer.msg('数据提交中...',{time:500000});
            $.ajax({
                type: "POST",
                url: _form.attr('action'),
                data: $('#forms').serialize(),
                success: function(res) {
                    if(res.code == 200) {
                        layer.alert(res.msg, {icon: 6},function () {
                            // 获得frame索引
                            var index = parent.layer.getFrameIndex(window.name);
                            //关闭当前frame
                            parent.layer.close(index);
                            parent.location.reload();
                        })
                    } else {
                        layer.msg(res.msg,{icon: 2});
                    }
                }
            });
            return false;
        });

    });
</script>
{include file="public/footer"/}